package uk.co.richardwkirk.parkrun.funnels.controllers;
import java.util.LinkedList;

import uk.co.richardwkirk.parkrun.funnels.model.FunnelSystem;
import uk.co.richardwkirk.parkrun.funnels.model.RaceFinishers;
import uk.co.richardwkirk.parkrun.funnels.model.Runner;


public class FinishController extends BaseController {

	RaceFinishers finishers = null;
	FunnelSystem funnels = null;
	
	public FinishController(RaceFinishers finishers_, FunnelSystem funnels_) {
		finishers = finishers_;
		funnels = funnels_;
	}

	@Override
	void processActions() {
		// On whole number of seconds we add some more finishers
		if (currentTime % 1 == 0) {
			LinkedList<Runner> nextFinishers = finishers.removeFinishersBefore(currentTime);
			funnels.addFinishers(nextFinishers);
		}
	}

}
